package com.neusoft.student.utils;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @Author: duan
 * @Date: Create in 16:52 2020/10/21
 */
public class RequestUtil {
    /**
     * 打印HttpServletRequest中的所有参数名称及值
     * @param req
     */
    public static void printRequestParams(HttpServletRequest req) {
        Map<String, String[]> parameterMap = req.getParameterMap();
        Set<String> keys = parameterMap.keySet();
        Iterator<String> iterator = keys.iterator();
        String key = null;
        String[] value = null;
        while(iterator.hasNext()) {
            key = iterator.next();
            value = parameterMap.get(key);
            System.out.println(key + ":" + Arrays.toString(value));
        }
    }
}
